<template>
  <div id="app">
    <router-view />
  </div>
</template>
<script>
import { mapState } from "vuex";
export default {
  name: "App",
  computed: {
    ...mapState("d2admin/sysConfig", ["info"]),
  },
  watch: {
    info: {
      deep: true,
      handler: function (val) {
        const { ico } = val;
        if (ico) {
          this.setIco({ ico });
        }
      },
    },
  },
  methods: {
    /**
     * 设置ico
     */
    setIco({ ico }) {
      var link = document.createElement("link");
      var oldLink = document.getElementById("dynamic-favicon");
      link.id = "dynamic-favicon";
      link.rel = "shortcut icon";
      if (ico) {
        link.href = ico;
        if (oldLink) {
          document.head.removeChild(oldLink);
        }
        document.head.appendChild(link);
      }
    },
  },
};
</script>

<style lang="scss">
@import "~@/assets/style/public-class.scss";
</style>
